﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ReAnimation.MVP.ViewInterfaces;
using ReAnimation.MVP.Models.Interfaces;
using ReAnimation.Infrastructure.Services.DomainFactories.Interfaces;
using ReAnimation.Helpers.WinForms;
using ReAnimation.Domain;

namespace ReAnimation.MVP.Presenters
{
    public class NewAnimationDialogPresenter:BasePresenter<INewAnimationDialogView>
    {
        private IMainModel _mainModel;
        private IAnimationFactory _animationFactory;

        public NewAnimationDialogPresenter(IMainModel mainModel,
                                           IAnimationFactory animationFactory)
        {
            _mainModel = mainModel;
            _animationFactory = animationFactory;
        }

        protected override void InitView()
        {
            _view.Create += new EventHandler<EventArg<string>>(_view_Create);
        }

        void _view_Create(object sender, EventArg<string> e)
        {
            Animation animation = _animationFactory.CreateAnimation();
            animation.Name = e.Data;
            _mainModel.CurrentAnimation = animation;
            _mainModel.CurrentAnimationStep = null;
            _mainModel.CurrentMolecule = null;
            _view.Close();
        }
    }
}